/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mif18.orm;

import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

/**
 *
 * @author Quentin
 * @EmbeddedId nous indique que nous pouvons utiliser cette classe comme une
 * clef primaire de deux éléments.
 */
@Embeddable
public class ClefComposition implements Serializable {

    /**
     * Relation unique 1 vers 1 donc relation OneToOne
     * Pour créer la clef
     */
    @OneToOne
    @JoinColumn(name = "vin")
    private Vin vin;
    private String variete;

    public void setVariete(String variete) {
        this.variete = variete;
    }

    public void setVin(Vin vin) {
        this.vin = vin;
    }

    public String getVariete() {
        return variete;
    }

    public Vin getVin() {
        return vin;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 53 * hash + (this.vin != null ? this.vin.hashCode() : 0);
        hash = 53 * hash + (this.variete != null ? this.variete.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ClefComposition other = (ClefComposition) obj;
        if (this.vin != other.vin && (this.vin == null || !this.vin.equals(other.vin))) {
            return false;
        }
        if ((this.variete == null) ? (other.variete != null) : !this.variete.equals(other.variete)) {
            return false;
        }
        return true;
    }
}
